package cn.tedu.oa.common.util;

import cn.tedu.oa.sys.entity.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.crypto.hash.SimpleHash;

import java.util.UUID;

public class ShiroUtils {
    /*获得用户*/
    public static User getPrincipal() {
        return (User) SecurityUtils.getSubject().getPrincipal();
    }

    /*获得盐值*/
    public static String getSalt() {
        return UUID.randomUUID().toString();
    }

    /*加密*/
    public static String encryption(String password,String salt) {
        return new SimpleHash("MD5", password, salt, 1000).toHex();
    }
}
